﻿@using Hotel.Application.Dics
@using Hotel.Application.Suppliers.Dto
@model SupplierCreateUpdateDto
@inject IDicService dicService
@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui.form小例子</title>
    <link rel="stylesheet" href="~/layuiAdmin/layui/css/layui.css" media="all">
</head>
<body>
    <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">供应商编号</label>
                <div class="layui-input-inline">
                    <input type="text" asp-for="SupplierCode" lay-verify="required" autocomplete="off" class="layui-input" placeholder="请输入供应商编号">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">供应商名称</label>
                <div class="layui-input-inline">
                    <input type="text" asp-for="SupplierName" lay-verify="required" placeholder="请输入供应商名称" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">供应商类型</label>
                <div class="layui-input-inline">
                    <select asp-for="SupplierType" lay-verify="required">
                        <option value="">--请选择--</option>
                        @foreach (var item in await dicService.QueryByCacheAsync("SupplierType"))
                        {
                            <option value="@item.DicValue">@item.DicName</option>
                        }
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">电话</label>
                <div class="layui-input-inline">
                    <input type="text" asp-for="Phone" lay-verify="required" placeholder="请输入供应商名称" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-inline">
                    <input type="text" asp-for="Email" lay-verify="required" autocomplete="off" class="layui-input" placeholder="请输入供应商编号">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">传真</label>
                <div class="layui-input-inline">
                    <input type="text" asp-for="Fax" lay-verify="required" placeholder="请输入供应商名称" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">联系人</label>
                <div class="layui-input-inline">
                    <input type="text" asp-for="Contact" lay-verify="required" autocomplete="off" class="layui-input" placeholder="请输入供应商编号">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">地址</label>
                <div class="layui-input-inline">
                    <input type="text" asp-for="Address" lay-verify="required" placeholder="请输入供应商名称" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">请填写描述</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item layui-hide">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
        <!-- 更多表单结构排版请移步文档左侧【页面元素-表单】一项阅览 -->
    </div>
    <script src="~/layuiAdmin/layui/layui.js"></script>
    <script>
        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form'], function () {
            var $ = layui.$
                , form = layui.form;

            //监听提交
            form.on('submit(layuiadmin-app-form-submit)', function (data) {
                var field = data.field; //获取提交的字段
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引

                $.ajax({
                    url:"@Url.Action("Create")",
                    data:field,
                    type:"post",
                    success:function(d){
                        if(d.code > 0){
                            layer.msg(d.msg, { time: 6000 })
                        }else{
                            //提交 Ajax 成功后，关闭当前弹层并重载表格
                            //$.ajax({});
                            parent.layui.table.reload('demo'); //重载表格
                            parent.layer.close(index); //再执行关闭
                        }
                    }
                })


                
            });
        })
    </script>
</body>
</html>